package com.ellricky.baselib.adapter.course;


import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.andr.common.ui.adapter.BaseRecyclerAdapter;
import com.andr.common.ui.adapter.SmartViewHolder;
import com.ellricky.baselib.R;
import com.ellricky.baselib.entity.course.CourseFileEntity;

public class CourseFileAdapter extends BaseRecyclerAdapter<CourseFileEntity> {

    private Activity context;
    private AdapterView.OnItemClickListener onItemClickListener;

    public CourseFileAdapter(Activity context, AdapterView.OnItemClickListener onItemClickListener) {
        super(R.layout.base_adapter_course_file);
        this.context = context;
        this.onItemClickListener = onItemClickListener;
    }

    @Override
    protected void onBindViewHolder(SmartViewHolder vh, CourseFileEntity p1, int i) {
        LinearLayout itemTitle = vh.itemView.findViewById(R.id.item_title);
        itemTitle.setVisibility(i == 0 ? View.VISIBLE : View.GONE);
        vh.text(R.id.tvCount, p1.getClassNum());
        vh.text(R.id.tvFileName, p1.getClassFileName());


        ImageView ivDel = vh.itemView.findViewById(R.id.ivDel);
        ivDel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               setOnItemClickListener(onItemClickListener);
            }
        });

    }
}